package test.m2.serviceimpl;

import org.fornax.cartridges.sculptor.framework.errorhandling.ServiceContext;

import javax.interceptor.Interceptors;

import test.m2.domain.X;
import test.m2.domain.XRepository;
import test.m2.exception.XNotFoundException;
import test.m2.serviceapi.BLocal;
import test.m2.serviceapi.BRemote;

/**
 * Generated base class for implementation of B.
 * <p>Make sure that subclass defines the following annotations:
 * <pre>
@javax.ejb.Stateless(name="b")

@Interceptors({org.fornax.cartridges.sculptor.framework.errorhandling.ServiceContextStoreInterceptor.class,
    org.fornax.cartridges.sculptor.framework.errorhandling.ErrorHandlingInterceptor.class})

 * </pre>
 */
public abstract class BBeanBase implements BLocal, BRemote {
    private static final long serialVersionUID = 1L;
    @javax.ejb.EJB
    private XRepository xRepository;

    public BBeanBase() {
    }

    protected XRepository getXRepository() {
        return xRepository;
    }

    /**
     * Delegates to {@link test.m2.domain.XRepository#findByKey}
     */
    @Interceptors({org.fornax.cartridges.sculptor.framework.errorhandling.JpaFlushEagerInterceptor.class
    })
    public X x(ServiceContext ctx, String name) throws XNotFoundException {
        return xRepository.findByKey(name);

    }

    /**
     * Delegates to {@link test.m2.domain.XRepository#save}
     */
    @Interceptors({org.fornax.cartridges.sculptor.framework.errorhandling.JpaFlushEagerInterceptor.class
    })
    public X save(ServiceContext ctx, X entity) {
        return xRepository.save(entity);

    }
}
